<?php
namespace App\Admin\Renderable;
use App\Admin\Repositories\Posts\WxTag;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class TagRender extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new WxTag(), function (Grid $grid) {
//            global $__MINI_GLOBAL_TENANT_ID__;
//            if($__MINI_GLOBAL_TENANT_ID__ > 0){
//                $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
//            }
            $grid->quickSearch(['id', 'tags_name'])->placeholder('搜索话题ID，名字...');
            $grid->model()->orderBy('tags_number','desc');
            $grid->column('id')->sortable();
            $grid->column('tags_name');
            $grid->column('sort')->editable();
            $grid->column('tags_number')->sortable();
            $grid->column('tags_state')->select([0=>'正常',1=>'隐藏']);
//            $grid->column('created_at');
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('tags_name');
                $filter->equal('tags_state')->select([0=>'正常',1=>'隐藏']);
            });
            $grid->disableBatchActions();
            $grid->disableActions();
        });
    }
}
